//
//  P2PMessenger.h
//  RunSketch
//
//  Created by Brian on 10/21/09.
//  Copyright 2009 Tellart. All rights reserved.
//

#import <GameKit/GameKit.h>
#import <Foundation/Foundation.h>

#define P2PMessengerStatus int
#define kP2PMessengerStatus_InvalidPeerID       -100
#define kP2PMessengerStatus_OK                  0

@protocol P2PMessengerDelegate;

@interface P2PMessenger : NSObject <GKSessionDelegate> {
    
	id <P2PMessengerDelegate> myDelegate;
    NSString *myPeerID;
    GKSession *mySession;
    NSData *dataToSend;
    
    BOOL connected;
}

@property (nonatomic, assign) id <P2PMessengerDelegate> myDelegate;
@property (nonatomic, retain) NSString *myPeerID;
@property (nonatomic, retain) NSData *dataToSend;
@property (nonatomic) BOOL connected;

- (P2PMessengerStatus) startAcceptingWithDelgate:(id <P2PMessengerDelegate>)delegate;
- (P2PMessengerStatus) stopAccepting;
- (P2PMessengerStatus) sendData:(NSData *)data to:(NSString *)toID;

- (void)session:(GKSession *)session peer:(NSString *)peerID didChangeState:(GKPeerConnectionState)state;
- (void)receiveData:(NSData *)data fromPeer:(NSString *)peer inSession: (GKSession *)session context:(void *)context;

@end

@protocol P2PMessengerDelegate <NSObject>
- (void) messenger:(P2PMessenger *)messenger didReceiveData:(NSData *)data from:(NSString *)fromID;
@end
